package com.aierjun.camera;

import android.app.Application;
import android.graphics.Bitmap;
import android.util.DisplayMetrics;

import com.aierjun.camera.utils.FileUtil;

public class AppInit {
    public static int mScreenWidth = 0;
    public static int mScreenHeight = 0;

    public static Application CONTEXT;

    private Bitmap mCameraBitmap;

    private static AppInit self = null;
    public static AppInit getInstance(){
        if (self == null)
            self = new AppInit();
        return self;
    }

    public void init(Application application){
        // DisplayMetrics mDisplayMetrics = new DisplayMetrics();
        DisplayMetrics mDisplayMetrics = application.getResources()
                .getDisplayMetrics();
        mScreenWidth = mDisplayMetrics.widthPixels;
        mScreenHeight = mDisplayMetrics.heightPixels;

        CONTEXT = application;

        FileUtil.initFolder();
    }

    public Bitmap getCameraBitmap() {
        return mCameraBitmap;
    }

    public void setCameraBitmap(Bitmap mCameraBitmap) {
        if (mCameraBitmap != null) {
            recycleCameraBitmap();
        }
        this.mCameraBitmap = mCameraBitmap;
    }

    public void recycleCameraBitmap() {
        if (mCameraBitmap != null) {
            if (!mCameraBitmap.isRecycled()) {
                mCameraBitmap.recycle();
            }
            mCameraBitmap = null;
        }
    }
}
